class LazySeg:
    def __init__(self, nums):
        self.nums = nums
        self.n = len(nums)
        self.tag = [0] * (4 * self.n)
        self.vals = [0] * (4 * self.n)
        self._build(0, self.n - 1, 1)

    def _build(self, l, r, x):
        vals = self.vals
        nums = self.nums
        if l == r:
            vals[x] = nums[l]
            return
        mid = (l + r) >> 1
        self._build(l, mid, x << 1)
        self._build(mid + 1, r, x << 1 | 1)
        self._update(x)

    def _update(self, x):
        vals = self.vals
        vals[x] = vals[x << 1] + vals[x << 1 | 1]

    def _down(self, l, r, x):
        tag = self.tag
        vals = self.vals
        mid = (l + r) >> 1
        if tag[x]:
            tag[x << 1] = tag[x << 1 | 1] = tag[x]
            vals[x << 1] = (mid - l + 1) - vals[x << 1]
            vals[x << 1 | 1] = (r - mid) - vals[x << 1 | 1]
            tag[x] = 0

    '''
    修改[A,B]
    '''
    def change(self, a, b, v):
        self._change(a, b, v, 0, self.n - 1, 1)

    def _change(self, A, B, v, l, r, x):
        tag = self.tag
        vals = self.vals
        if A <= l and r <= B:
            tag[x] = v
            vals[x] = v * (r - l + 1)
            return
        self._down(l, r, x)
        mid = (l + r) >> 1
        if A <= mid: self._change(A, B, v, l, mid, x << 1)
        if mid < B: self._change(A, B, v, mid + 1, r, x << 1 | 1)
        self._update(x)

    def _query(self, A, B, l, r, x):
        vals = self.vals
        if A <= l and r <= B:
            return vals[x]
        self._down(l, r, x)
        mid = (l + r) >> 1
        ret = 0
        if A <= mid: ret += self._query(A, B, l, mid, x << 1)
        if mid < B: ret += self._query(A, B, mid + 1, r, x << 1 | 1)
        return ret

    def query(self, a, b):
        return self._query(a, b, 0, self.n - 1, 1)
